package mlta.activities;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.Toast;

public class NewTopicActivity extends Activity {
	protected Button bCancel, bPublic;
	protected Button btn_help, btn_exit, btn_home, btn_refresh, btn_search, btn_new, btn_back;
	protected EditText tTitulo, tMsg;
	protected Spinner sPriv;
	
	protected long course_id = -1;
	protected String username;
	protected boolean novo = false;

	protected String titulo;

	protected String message;
	
	    @Override
	    public void onCreate(Bundle savedInstanceState) {
		    super.onCreate(savedInstanceState);
		    this.requestWindowFeature(Window.FEATURE_NO_TITLE);
	        setContentView(R.layout.new_topic);
	        
	        course_id = getIntent().getLongExtra("course_id", -1);
	        username = getIntent().getStringExtra("username");
	        novo = getIntent().getBooleanExtra("novo", false);
			titulo = getIntent().getStringExtra("titulo");
			message = getIntent().getStringExtra("message");
	        
	        btn_help = (Button) findViewById(R.id.new_help);
	        btn_exit = (Button) findViewById(R.id.new_exit);
	             
	        btn_help.setOnClickListener(new View.OnClickListener() {
				
				@Override
				public void onClick(View arg0) {
					Toast.makeText(getApplicationContext(), "Feature not ready yet!!!", Toast.LENGTH_LONG).show();
				}
				
			});
	        
	        btn_exit.setOnClickListener(new View.OnClickListener() {
				
				@Override
				public void onClick(View arg0) {
					System.exit(0);
				}
				
			});
	        
	     	        
	        bCancel = (Button) findViewById(R.id.btnCanc);
	        bPublic = (Button) findViewById(R.id.btnPublic);
	        tTitulo = (EditText) findViewById(R.id.editTitulo);
	        tMsg = (EditText) findViewById(R.id.editMsg);
	        sPriv = (Spinner) findViewById(R.id.spinnerPriv);
	        
	        bCancel.setOnClickListener(new View.OnClickListener() {
	            
	            public void onClick(View v) {
	            	Intent intent = new Intent(NewTopicActivity.this, CoursesTopicActivity.class);
	            	intent.putExtra("id", course_id);
					intent.putExtra("username", username);
					intent.putExtra("novo", novo);
					intent.putExtra("titulo", titulo);
					intent.putExtra("message", message);
					NewTopicActivity.this.startActivity(intent);
	            	System.exit(0);
	            }
	        });
	        
	        bPublic.setOnClickListener(new View.OnClickListener() {
				
				@Override
				public void onClick(View v) {
					String titulo = tTitulo.getText().toString();
					String message = tMsg.getText().toString();
					novo = true;
					Intent intent = new Intent(NewTopicActivity.this, CoursesTopicActivity.class);
					intent.putExtra("username", username);
					intent.putExtra("novo", novo);
					intent.putExtra("titulo", titulo);
					intent.putExtra("message", message);
	            	intent.putExtra("id", course_id);
					NewTopicActivity.this.startActivity(intent);
					System.exit(0); 
				}
				
			});
	        
	 }
	    
	    @Override
	    public void onBackPressed() {
			Intent intent = new Intent(NewTopicActivity.this,
					CoursesTopicActivity.class);
        	intent.putExtra("id", course_id);
			intent.putExtra("username", username);
			intent.putExtra("novo", novo);
			intent.putExtra("titulo", titulo);
			intent.putExtra("message", message);
			NewTopicActivity.this.startActivity(intent);
			System.exit(0);
	    } 
	    
}
